import axios from 'axios'
export default {
  namespaced: true,
  state: {
    category: [],
    currentCategory: 0
  },
  // 状态修改
  mutations: {
    // 更新分类
    updateCategory (state, payload) {
      state.category = payload
    },
    // 更新当前分类ID
    updateCurrentCategory (state, currentCategory) {
      state.currentCategory = currentCategory
    }
  },
  // 异步请求
  actions: {
    async getCategory ({ commit }) {
      const { data: { data: { channels } } } = await axios({ url: 'http://192.168.11.34:8000/v1_0/channels' })
      commit('updateCategory', channels)
    }
  }
}
